#include "connection_manage.h"

#include <algorithm>

#include <boost\bind.hpp>

#include "log.h"

namespace jump
{
	namespace client
	{
		//single start
		void Connection_Manage::start(connection_ptr arg_c)
		{
			connections_.insert(arg_c);
			arg_c->start();

			LOG_PRINTF("Connecting Clients Num:%d",this->connections_.size());
		}

		//single stop
		void Connection_Manage::stop(connection_ptr arg_c)
		{
			connections_.erase(arg_c);
			arg_c->stop();

			LOG_PRINTF("Connecting Clients Num:%d",this->connections_.size());

		}

		void Connection_Manage::stop_all()
		{

			std::for_each(connections_.begin(),
				connections_.end(),
				boost::bind(&Connection::stop,_1));

			//clear set
			connections_.clear();
		}

	}//namespace client
}//namespace jump